package com.zzy.pool.pool2.poolobj;

import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.junit.Test;

public class TestMain {

	
	@Test
	public void testMa(){
		
		GenericObjectPoolConfig conf = new GenericObjectPoolConfig();
        conf.setMaxTotal(10);
        GenericObjectPool<String> pool = new GenericObjectPool<String>(new StringFactory(), conf);
        for(int i=0;i<8;i++){
            System.out.println(i+":");
            try {
                String str = pool.borrowObject();  //拿出
                
                System.out.println(str);
                
                pool.returnObject(str);  //释放
            } catch (Exception e) {
                e.printStackTrace();
            }           
       }
	}
}
